﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace InspectionMAC.SystemThread
{
    class TestDioThread
    {
        public static bool TestDio_Flowrec = false;
        public static Thread TestDioFlow_Thread = null;
        public static int iTestDio_Step = 0;

        public static bool TestDio_Stop = false;

        public static DateTime triggerDataTime;
        public static void TestDio_Thread()
        {
            TestDio_Flowrec = true;
            TestDioFlow_Thread = new Thread(TestDioFlowThread);
            TestDioFlow_Thread.IsBackground = true;
            TestDioFlow_Thread.Start();
        }
        private static void TestDioFlowThread(object obj)
        {
            while (TestDio_Flowrec)
            {
                switch (iTestDio_Step)
                {
                    case 10:
                        DIO_Thread.Do[1] = 1;
                        Thread.Sleep(10);
                        DIO_Thread.Do[1] = 0;
                        iTestDio_Step = 45;
                        break;
                    case 15:

                        break;
                    case 20:
                        DIO_Thread.Do[2] = 1;
                        Thread.Sleep(50);
                        DIO_Thread.Do[2] = 0;
                        iTestDio_Step = 45;
                        break;
                    case 25:

                        break;
                    case 30:
                        DIO_Thread.Do[3] = 1;
                        Thread.Sleep(50);
                        DIO_Thread.Do[3] = 0;
                        iTestDio_Step = 45;
                        break;
                    case 31:
                        DIO_Thread.Do[10] = 1;
                        Thread.Sleep(100);
                        Console.WriteLine("踢料动作触发");
                        DIO_Thread.Do[10] = 0;
                        iTestDio_Step = 45;
                        break;
                    case 32:
                        DIO_Thread.Do[10] = 1;
                        Thread.Sleep(200);
                        DIO_Thread.Do[10] = 0;
                        iTestDio_Step = 45;
                        break;
                    case 33:
                        DIO_Thread.Do[10] = 1;
                        Thread.Sleep(300);
                        DIO_Thread.Do[10] = 0;
                        iTestDio_Step = 45;
                        break;
                    case 35:

                        break;
                    case 40:
                        Thread.Sleep(1000);
                        if (DIO_Thread.Di[5] != 1)
                        {
                            DIO_Thread.Do[14] = 1;
                            Thread.Sleep(50);
                            DIO_Thread.Do[14] = 0;
                        }
                        break;
                    case 45:

                        break;
                }
            }
        }
    }
}
